package interpreters;

import java.util.*;
import org.hibernate.Transaction;
import Factory.HibernateSessionFactory;
import dataObjects.Dose;
import dataObjects.DoseDAO;

public class ReminderChecker {
	public static List<String> getReminders(String userName){
//		GregorianCalendar gc = new GregorianCalendar();
//		int day_of_week = gc.get(Calendar.DAY_OF_WEEK);
//		int minute_of_day = gc.get(Calendar.HOUR_OF_DAY) * 60 + gc.get(Calendar.MINUTE);
//		
//		List<Dose> doses;
//		DoseDAO doseDao = new DoseDAO();
//		//HibernateSessionFactory.setConfigFile(HibernateSessionFactory.CONFIG_FILE_LOCATION_USER);
//		Transaction tx = doseDao.getSession().beginTransaction();
//		doses = doseDao.findByUserName(userName);
//		tx.commit();
//		doseDao.getSession().close();
//		
//		LinkedList<String> reminders = new LinkedList<String>();
//		
//		for(Dose d:doses){
//			String[] schedule = d.getFrequency().split(",");
//			int interval = d.getReminder();
//			for(String s:schedule){
//				String[] time = s.split("-");
//				if(remind(day_of_week, minute_of_day, Integer.parseInt(time[0]), 
//						Integer.parseInt(time[1].trim()), interval)) 
//					reminders.add(d.getId().getMedicine() + "-" +
//							Integer.parseInt(time[1].trim())/60 + ":" + Integer.parseInt(time[1].trim())%60 +  "-" +
//							DetailedScheduleGenerator.dayStrings[Integer.parseInt(time[0].trim())]);
//			}
//		}
		
		return null;//reminders;
	}
	
	private static boolean remind(int curDay, int curMin, int doseDay, int doseMin, int gap){
		if(doseDay == curDay && doseMin > curMin && doseMin <= curMin + gap) return true;
		if((doseDay == curDay + 1 || (doseDay == 0 && curDay == 6)) && doseMin + 1440 > curMin && doseMin + 1440 <= curMin + gap) return true;
		return false;
	}
}
